package com.buba.user.service.impl;

import com.buba.pojo.other.DivisionType;
import com.buba.pojo.other.HospitalGuide;
import com.buba.pojo.other.PackageYpe;
import com.buba.pojo.other.SetMeal;
import com.buba.pojo.system.Health;
import com.buba.pojo.system.NewsBulletin;
import com.buba.pojo.user.Campus;
import com.buba.pojo.user.Doctor;
import com.buba.pojo.user.User;
import com.buba.user.mapper.CampusMapper;
import com.buba.user.mapper.DoctorMapper;
import com.buba.user.pojo.CampusVo;
import com.buba.user.pojo.DivisionVo;
import com.buba.user.pojo.DoctorVo;
import com.buba.user.pojo.MealVo;
import com.buba.user.service.DoctorService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * <p>
 * 医生表 服务实现类
 * </p>
 *
 * @author testjava
 * @since 2022-06-09
 */
@Service
public class DoctorServiceImpl extends ServiceImpl<DoctorMapper, Doctor> implements DoctorService {

    @Autowired
    private DoctorMapper doctorMapper;

    @Override
    public List<Doctor> getDoctors(String day) {
        return doctorMapper.getDoctors(day);
    }

    @Override
    public List<com.buba.user.pojo.DoctorVo> findDoctorAll() {
        return doctorMapper.findDoctorAll();
    }

    @Override
    public List<DivisionVo> findDivisionAll() {
        return doctorMapper.findDivisionAll();
    }

    @Override
    public List<Health> findHealthAll() {
        return doctorMapper.findHealthAll();
    }

    @Override
    public List<CampusVo> findCampusAll() {
        return doctorMapper.findCampusAll();
    }

    private CampusMapper campusMapper;

    @Override
    public int addDoctor(DoctorVo doctorVo, Doctor doctor, Campus campus, DivisionType divisionType) {
        Campus c = new Campus();
        campus.setCampusName(doctorVo.getCampusName());
//         c.setCampusName(doctorVo.getCampusName());
//        campusMapper.insert(c);
        doctorMapper.addDoctor1(campus);
//        DivisionType dt = new DivisionType();
//        dt.setDivisionName(doctorVo.getDivisionName());
        divisionType.setDivisionName(doctorVo.getDivisionName());
        doctorMapper.addDoctor2(divisionType);
//        Doctor d= new Doctor();
//        doctorName:'',img:'',campusName:'',jobTitle:'',divisionName:'',labels:'',introduction:''}
        doctor.setDoctorName(doctorVo.getDoctorName());
        doctor.setImg(doctorVo.getImg());
        doctor.setJobTitle(doctorVo.getJobTitle());
        doctor.setLabels(doctorVo.getLabels());
        doctor.setIntroduction(doctorVo.getDoctorName());
        doctor.setDistrictId(divisionType.getId());
        doctor.setAdministrativeId(campus.getId());
        doctor.setRegistration(doctorVo.getRegistration());
        doctor.setIndagation(doctorVo.getIndagation());

        Date date = new Date();  // 获取当前系统时间
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  // 设置日期格式
        String strTime = simpleDateFormat.format(date);  // 格式转换
        doctor.setUpdateTime(date);
        doctor.setCreateTime(date);

        doctor.setState(0);
        doctor.setDeleteFlag("0");
        int i = doctorMapper.addDoctor(doctor);
        return i;
    }

    @Override
    public int updDoctor(DoctorVo doctorVo, Doctor doctor, Campus campus, DivisionType divisionType) {

        int i = doctorMapper.updDoctor(doctorVo);
        int i1 = doctorMapper.updDoctor1(campus);
        int i2 = doctorMapper.updDoctor2(divisionType);
        return i;
    }

    @Override
    public int delDoctor(Doctor doctor) {
        int i = doctorMapper.delDoctor(doctor);
        return i;
    }

    @Override
    public List<DoctorVo> mhcAdd(String doctorName, String divisionName) {
//        DoctorVo doctorVo1 = new DoctorVo();
        return doctorMapper.mhcAdd(doctorName,divisionName);
    }

    @Override
    public int addDivision(DivisionVo divisionVo) {
        int i = doctorMapper.addDivision(divisionVo);
        int i1 = doctorMapper.addDivision1(divisionVo);
        int i2 = doctorMapper.addDivision2(divisionVo);
        return i;
    }

    @Override
    public int updDivision(DivisionVo divisionVo, DivisionType divisionType, Campus campus, HospitalGuide hospitalGuide) {
        int i = doctorMapper.updDivision(divisionVo);
        int i1 = doctorMapper.updDivision1(hospitalGuide);
        int i2 = doctorMapper.updDivision2(campus);
        return i;
    }

    @Override
    public int delDepartment(DivisionType divisionType) {
        return doctorMapper.delDepartment(divisionType);
    }

    @Override
    public List<DivisionVo> Depmhc(String campusName, String divisionName) {
        return doctorMapper.Depmhc(campusName,divisionName);
    }

    @Override
    public int Healthy(Health health) {
        Date date = new Date();  // 获取当前系统时间
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  // 设置日期格式
        String strTime = simpleDateFormat.format(date);  // 格式转换
        health.setCreateTime(date);
        health.setUpdateTime(date);
        health.setHState("1");

        int i = doctorMapper.Healthy(health);
        return i;
    }

    @Override
    public int updHealth(Health health) {
        return doctorMapper.updHealth(health);
    }
    @Override
    public int mtkHealth(Health health) {
        return doctorMapper.mtkHealth(health);
    }

    @Override
    public List<Health> Heamhc(String htitle) {
        return doctorMapper.Heamhc(htitle);
    }

    @Override
    public List<MealVo> finMealAll() {
        return doctorMapper.finMealAll();
    }

    @Override
    public int MealAdd(MealVo mealVo , SetMeal setMeal, Campus campus , PackageYpe packageYpe ) {
        campus.setCampusName(mealVo.getCampusName());
        int id = doctorMapper.MealAdd1(campus);

        packageYpe.setPkName(mealVo.getPkName());
        mealVo.setPkState("1");
        mealVo.setPkMenu(mealVo.getPkMenu());
        setMeal.setUpdateTime(packageYpe.getUpdateTime());
        setMeal.setCreateTime(packageYpe.getCreateTime());

        int i2 = doctorMapper.MealAdd2(packageYpe);

        Date date = new Date();  // 获取当前系统时间
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  // 设置日期格式
        String strTime = simpleDateFormat.format(date);  // 格式转换
        setMeal.setCreateTime(date);
        setMeal.setUpdateTime(date);
        setMeal.setDeleteFlag("0");
        setMeal.setState(0);
        setMeal.setSetMealName(mealVo.getSetMealName());
        setMeal.setImg(mealVo.getImg());
        setMeal.setProject(mealVo.getProject());
        setMeal.setTypeId(campus.getId());
        setMeal.setPrice(mealVo.getPrice());
        setMeal.setDistrictId(packageYpe.getId());
        int i = doctorMapper.MealAdd(setMeal);

        return i;
    }

    @Override
    public int MealUpd(MealVo mealVo , SetMeal setMeal, Campus campus , PackageYpe packageYpe) {
        int i = doctorMapper.MealUpd(setMeal);
        int i1 = doctorMapper.MealUpd1(campus);
        int i2 = doctorMapper.MealUpd2(packageYpe);
        return i;
    }

    @Override
    public int delMeal(MealVo mealVo) {
        return doctorMapper.delMeal(mealVo);
    }

    @Override
    public List<PackageYpe> findPackAll() {
        return doctorMapper.findPackAll();
    }

    @Override
    public int pkAdd(PackageYpe packageYpe) {
        Date date = new Date();  // 获取当前系统时间
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  // 设置日期格式
        String strTime = simpleDateFormat.format(date);  // 格式转换
        packageYpe.setCreateTime(date);
        packageYpe.setUpdateTime(date);
        packageYpe.setDeleteFlag("0");
        int i =  doctorMapper.pkAdd(packageYpe);
        return i;
    }

    @Override
    public int pkUpd(PackageYpe packageYpe) {
        return doctorMapper.pkUpd(packageYpe);
    }

    @Override
    public int delpk(PackageYpe packageYpe) {
        return doctorMapper.delpk(packageYpe);
    }

    @Override
    public List<PackageYpe> lxmhc(String pkName) {
        return doctorMapper.lxmhc(pkName);
    }
    @Override
    public List<MealVo> taomtk(String setMealName) {
        return doctorMapper.taomtk(setMealName);
    }

    @Override
    public List<User> findAdminAll() {
        return doctorMapper.findAdminAll();
    }

    @Override
    public int AddAdmin(User user) {
        user.setPassword("123");
        Date date = new Date();  // 获取当前系统时间
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  // 设置日期格式
        String strTime = simpleDateFormat.format(date);  // 格式转换
        user.setCreationTime(date);
        user.setModificationTime(date);
        int i =  doctorMapper.AddAdmin(user);
        return i;
    }

    @Override
    public int UpdAdmin(User user) {
        return doctorMapper.UpdAdmin(user);
    }

    @Override
    public List<User> mhcAdmin(String userName) {
        return doctorMapper.mhcAdmin(userName);
    }

    @Override
    public int shanchu(String id) {
        return doctorMapper.shanchu(id);
    }

    @Override
    public List<NewsBulletin> findMessageAll() {
        return doctorMapper.findMessageAll();
    }

    @Override
    public int MessageAdd(NewsBulletin newsBulletin) {
        newsBulletin.setNewsState("1");
        Date date = new Date();  // 获取当前系统时间
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  // 设置日期格式
        String strTime = simpleDateFormat.format(date);  // 格式转换
        newsBulletin.setCreateTime(date);
        newsBulletin.setUpdateTime(date);
        int i = doctorMapper.MessageAdd(newsBulletin);
        return i;
    }

    @Override
    public int MessageUpd(NewsBulletin newsBulletin) {
        return doctorMapper.MessageUpd(newsBulletin);
    }

    @Override
    public int MessageDel(String id) {
        return doctorMapper.MessageDel(id);
    }

    @Override
    public List<NewsBulletin> mhcMessage(String newsTitle) {
        return doctorMapper.mhcMessage(newsTitle);
    }
    @Override
    public List<NewsBulletin> findMessageAlls() {
        return doctorMapper.findMessageAlls();
    }

    @Override
    public int MessageAdds(NewsBulletin newsBulletin) {
        newsBulletin.setNewsState("0");
        Date date = new Date();  // 获取当前系统时间
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  // 设置日期格式
        String strTime = simpleDateFormat.format(date);  // 格式转换
        newsBulletin.setCreateTime(date);
        newsBulletin.setUpdateTime(date);
        int i = doctorMapper.MessageAdds(newsBulletin);
        return i;
    }

    @Override
    public int MessageUpds(NewsBulletin newsBulletin) {
        return doctorMapper.MessageUpds(newsBulletin);
    }

    @Override
    public int MessageDels(String id) {
        return doctorMapper.MessageDels(id);
    }

    @Override
    public List<NewsBulletin> mhcMessages(String newsTitle) {
        return doctorMapper.mhcMessages(newsTitle);
    }

    @Override
    public int mimaUpd(Integer id,String password) {
        return doctorMapper.mimaUpd(id,password);
    }

}
